package com.lr.falsework.base;

import java.util.Calendar;
import java.util.Date;

import com.github.pagehelper.PageHelper;
import com.lr.falsework.common.bean.PageBean;
import com.lr.falsework.common.tool.WebContainerTool;
import com.ws.commons.constant.OperTypeEnum;
import com.ws.commons.interfac.Result;
import com.ws.mybatissmart.annotation.ColumnInfo;
 
public class BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected String id;
	@ColumnInfo(dateFormart = "yyyy-MM-dd HH:mm:ss", isUpdate = false)
	protected Date createTime;
	@ColumnInfo(dateFormart = "yyyy-MM-dd HH:mm:ss")
	protected Date updateTime;
	@ColumnInfo(isUpdate = false)
	protected String createUser;
	protected String updateUser;

//	@JsonIgnore
	transient protected PageBean page;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCreateUser() {
		return createUser;
	}

	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public PageBean getPage() {
		return page;
	}

	public void setPage(PageBean page) {
		this.page = page;
	}

	public void startIfPageIng() {
		if (page != null) {
			PageHelper.startPage(page.getPage(), page.getLimit());
		}
	}

	public void dftVal(OperTypeEnum operTypeEnum) {
		Date dt = Calendar.getInstance().getTime();
		switch (operTypeEnum) {
		case ADD:
			this.createTime = dt;
			this.createUser = WebContainerTool.getCurrentUser().getAccount();
			break;
		case UPDATE:
			this.updateTime = dt;
			this.updateUser = WebContainerTool.getCurrentUser().getAccount();
			break;
		default:
			Result.sysError().throwIfError();
			break;
		}
	}

	public void validVal(OperTypeEnum operTypeEnum) {

	}

}
